#pragma once
class IndexedGeometry;
class Material;
class ShaderMaterial;
/**
* This class binds an indexbuffer to a material.
* This is useful when one VertexBuffer object is used
* by multiple IndexBuffer objects.
* @author Koen Samyn
*/
class IndexBufferMaterial
{
public:
	/**
	* Creates a new IndexBufferMaterial object.
	* @param ib the IndexBuffer.
	*/ 
	IndexBufferMaterial(IndexedGeometry* ib);
	/**
	* Creates a new IndexBufferMaterial object.
	* @param ib the IndexBuffer
	* @param material the material to use for this IndexBuffer.
	*/
	IndexBufferMaterial(IndexedGeometry* ib,Material* material);
	/**
	* Destroys the IndexBuffer material object.
	*/
	virtual ~IndexBufferMaterial(void);
	/**
	* Returns the material for this IndexBufferMaterial object.
	* @return the material object.
	*/
	Material* GetMaterial(){return m_pMaterial;}
	/**
	* Sets the shader material for this IndexBuffer material object.
	* @param shaderMaterial the shader material to set.
	*/
	void SetMaterial(Material * m){m_pMaterial = m;m_MaterialSet=true;}
	/**
	* Returns the compiled shader material for this IndexBufferMaterial object.
	* @return the ShaderMaterial object.
	*/
	ShaderMaterial* GetShaderMaterial(){return m_pShaderMaterial;}
	/**
	* Sets the ShaderMaterial for this IndexBufferMaterial object.
	*/
	void SetShaderMaterial(ShaderMaterial* material);
	/**
	* Checks if a material was set for this indexbuffer.
	* @return true if the material was set, false otherwise.
	*/
	bool IsMaterialSet(){return m_MaterialSet;}
	/**
	* Returns the indexbuffer from this IndexBufferMaterial object.
	* @return the IndexBuffer object.
	*/
	IndexedGeometry* GetIndexBuffer(){return m_pIndexBuffer;}
private :
	/**
	* The indexbuffer object
	*/
	IndexedGeometry* m_pIndexBuffer;
	/**
	* The material to use.
	*/
	Material* m_pMaterial;
	/**
	* The compiled shader material.
	*/
	ShaderMaterial*m_pShaderMaterial;
	/**
	* Indicates that the material has been set.
	*/
	bool m_MaterialSet;
};
